<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<script type="text/javascript">
	var grid_ae = null;
	var dialog_ae = null;
	$(function(){
		grid_ae = $("#product_grid").ligerGrid({
				checkbox: true,
                columns: [
                { display: '产品id', name: 'id', isSort : false, width: 120 },
                { display: '名称', name: 'name',isSort : false, width: 200 },
                { display: '类型', name: 'type',isSort : false, width: 200 }, 
                { display: '创建时间', name: 'gmtCreated',isSort : false,
                  render: function(record, rowindex, value, column){
                	 return (new Date(value.time)).format("yyyy年MM月dd日 hh:mm:ss");
                  }}, 
                { display: '最后修改时间', name: 'gmtModified',isSort : false,
                  render: function(record, rowindex, value, column){
                	 return (new Date(value.time)).format("yyyy年MM月dd日 hh:mm:ss");
                  }
                },
                {
                	display: '<a href="javascript:;" onclick="addProduct()">新增产品</a>', 
                	name: 'id',
                	isAllowHide: false, 
                	isSort : false,
					render: function (record, rowindex, value, column){
					//this     这里指向grid
					//record   行数据
					//rowindex 行索引
					//value    当前的值，对应record[column.name]
					//column   列信息
						var html = '<a onclick="priceDetail(\''+ value + '\')" href="javascript:;">详细日期价格</a>&nbsp;<a onclick="editProduct(\''+ value + '\')" href="javascript:;">编辑</a>&nbsp;<a onclick="deleteProduct(\''+ value + '\')" href="javascript:;">删除</a>&nbsp;<a target="_blank" href="/product.htm?id='+record.id+'">预览</a>'; 
						return html;
					}
                }
                ], 
                pageSize:10,
                root :'list',
                record:'totalRecord',
                url: "/misc/product/productGrid.htm", 
                width: '99%',height:'99%',
                isChecked: f_isChecked, onCheckRow: f_onCheckRow, onCheckAllRow: f_onCheckAllRow
            });

		$("#parent").ligerComboBox({
			width : 215,
			selectBoxWidth : 215,
			selectBoxHeight : 180,
			valueField : 'mark',
			textField : 'text',
			treeLeafOnly : false,
			tree : {
				checkbox : false,
				btnClickToToggleOnly : false,
				url : '/misc/cms/channelTree.htm'
			}
		});

	});
	
	function deleteProduct(productId){
		$.ligerDialog.confirm('你真的要删除吗？', 
			function (yes){
				if(yes){
					$.post("/misc/product/deleteProduct.htm",{productId:productId}); 
					grid_ae.loadData();
				}
			});
	}
	
	function editProduct(id){
		dialog_ae = $.ligerDialog.open({ height: 700,width:900, url: "/misc/product/editProduct.htm?id="+id, isResize: false ,showMax:true,modal:true,title:'编辑产品'});
	}
	
	function addProduct(){
		dialog_ae = $.ligerDialog.open({ height: 700,width:900, url: "/misc/product/addProduct.htm", isResize: false ,showMax:true,modal:true,title:'新增产品'});
	
	}
	
	function priceDetail(id){
		dialog_ae = $.ligerDialog.open({ height: 500,width:700, url: "/misc/product/priceDetail.htm?productId="+id, showMax:true,showMin:true,isResize:true,isDrag:false,title:'详细日期价格	'});
	}
	
	function search(){
		grid_ae.options.parms = [{name:'name',value:$("#search_name").val()},{name:'company',value:$("#company").val()},{name:'type',value:$("#search_type").val()}];
		grid_ae.loadData();
	}
	
</script>
<table>
	<tr>
		<td>
			<div id="searchbar">
			  名称：<input id="search_name" type="text" value="${name}"/>
			    产品类型：<select id="search_type">
			    	<option value="">请选择</option>
			    	<option value="01">特价美食</option>
			    	<option value="02">旅游商品</option>
			    	<option value="03">线路推荐</option>
			    </select>
			</div>
		</td>
		<td>所属公司：</td>
		<td><%@include file="../company/companyName.jsp" %></td>
		<td><input id="btnOK" type="button" value="查询" onclick="search()" /></td>
		<td><input type="text" id="parent"/><button onclick="pushProduct()" id="tui_song" style="position:relative;left:220px;top:-22px; margin:0 0 -20px 0;">推送</button></td>
	</tr>
</table>
<div id="product_grid" style="margin:0; padding:0"></div>
